﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace KTV
{
    class DBHelper
    {
        public static string constr = "server=.;database=DBsong;Integrated Security=true";

        public static DataTable Select(string sql)
        {
            SqlConnection conn = new SqlConnection(constr);
            conn.Open();
            SqlDataAdapter da = new SqlDataAdapter(sql,conn);
            DataTable dt = new DataTable();
            da.Fill(dt);
            return dt;
        }

        public static bool Nonquery(string sql)
        {

            bool result = false;
            SqlConnection conn = new SqlConnection(constr);
            conn.Open();
            SqlCommand cmd = new SqlCommand(sql, conn);

            int number = cmd.ExecuteNonQuery();
            if (number > 0)
            {
                result = true;
                
            }
            conn.Close();
            return result;

        }

    }
}
